﻿<html>
	<body background="pic/background_06.gif">
	<head>
		<font face="新細明體,time new roman,Arial">
		<meta charset="UTF-8">
	</head>
	<body>
		<center>
			<font size="5" color="#0000FF"><b>--- 新增站别 ---</b></font><br>
			<hr>
			<?php
				// Loading all php class variable and fucntions ...
				require_once('class_package/common.php');
				
				
				//  ...setting_create function setting_create($wsid,$create_by,$create_time,$update_by,$update_time) 
				$get_prgm_wsid = trim($_POST['partnum']);
				$get_prgm_user				= trim($_COOKIE['login_user']);

				$get_prgm_wsid=strtoupper($get_prgm_wsid);
				$createTime= Date("Y:m:d H:i:s");
				
				$updateTime= "";
				$updateUser= "";
				if(empty($get_prgm_user)){
					echo "<script> alert('用户未登录，请登陆后操作！登录用户：$get_prgm_user');history.go(-1);</script>";
					exit();
					
				}
				
				if($get_prgm_user!="root"&$get_prgm_user!="binz_zhang"&$get_prgm_user!="guangshui_xu"){
					echo "<script> alert('该用户没有新增站别权限：$get_prgm_user');</script>";
					exit();
				}
				//站别不能时是中文
				if( preg_match('/[\x{4e00}-\x{9fa5}]/u', $get_prgm_wsid)>0) {
					echo "<script> alert('创建失败！站别不能存在中文！');history.go(-1);</script>";
					exit();
				} 
				if($get_prgm_wsid == "" ||$get_prgm_user =="" ){
					echo "<script> alert('创建失败！站别不能为空！');history.go(-1);</script>";
				} else {
						//查询站位是否已经存在
						$is_result=setting_select($get_prgm_wsid);
						if(!$is_result){
							echo "<script> alert('数据库异常！');</script>";
							exit();
						}
						
						
						$rows = mysqli_num_rows($is_result);		// 返回结果集中栏位的数量。
						if($rows>0){
							echo "<script> alert('站别已经存在，请勿重复创建！');history.go(-1);</script>";
							exit();
						}
						
						
						$result =setting_create($get_prgm_wsid,$get_prgm_user,$createTime,$updateUser,$updateTime);
						if($result){
							echo "<script> alert('创建成功！');history.go(-1);</script>";
						}else{
							echo "<script> alert('创建失败！数据库异常');history.go(-1);</script>";
						}
				}								
				exit();
			?>
		</center>
	</body>
</html>

<script>
	
</script>










